home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////
- // rtst.cpp: Test program for rational number class
- // Copyright(c) 1992 Azarona Software
- /////////////////////////////////////////////////////////
- #include <iostream.h>
- #include "rational.h"
-
- main()
- {
- Rational x, y, z;
-
- while(1) {
- cout << "Enter first rational number (w or <n/d>): ";
- cin >> x;
- if (cin) {
- cout << "Enter second rational number (w or <n/d>): ";
- cin >> y;
- }
- if (cin) {
- cout << "-" << x << " = " << (-x) << '\n';
- cout << "-" << y << " = " << (-y) << '\n';
- cout << "+" << x << " = " << (+x) << '\n';
- cout << "+" << y << " = " << (+y) << '\n';
- cout << x << " * " << y << " = " << (x * y) << '\n';
- cout << x << " / " << y << " = " << (x / y) << '\n';
- cout << x << " + " << y << " = " << (x + y) << '\n';
- cout << x << " - " << y << " = " << (x - y) << '\n';
- cout << x << " == " << y << " = " << (x == y) << '\n';
- cout << x << " != " << y << " = " << (x != y) << '\n';
- cout << x << " <= " << y << " = " << (x <= y) << '\n';
- cout << x << " >= " << y << " = " << (x >= y) << '\n';
- cout << x << " < " << y << " = " << (x < y) << '\n';
- cout << x << " > " << y << " = " << (x > y) << '\n';
- cout << x << "++ = ";
- z = x++;
- cout << z << '\n';
- cout << x << "-- = ";
- z = x--;
- cout << z << '\n';
- cout << "++" << x << " = ";
- z = ++x;
- cout << z << '\n';
- cout << "--" << x << " = ";
- z = --x;
- cout << z << '\n';
- }
- else {
- cout << "That's not very rational!\n";
- break;
- }
- }
- return 0;
- }
-